# Contributor: Max Rees <maxcrees@me.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=physlock
pkgver=13_git20200116
_gitrev=4fbacee834abef613d7f4bd37d52a9f5fe269c82
pkgrel=1
pkgdesc="Lightweight linux console locking tool"
url="https://github.com/muennich/physlock"
arch="all"
license="GPL-2.0-or-later"
makedepends="elogind-dev linux-headers linux-pam-dev"
subpackages="$pkgname-doc $pkgname-elogind"
source="https://github.com/muennich/physlock/archive/$_gitrev/$pkgname-$_gitrev.tar.gz
	physlock.pam
	"
builddir="$srcdir/$pkgname-$_gitrev"
options="!check suid" # No test suite

prepare() {
	default_prepare
	cp -r "$builddir" "$builddir-elogind"
}

build() {
	make HAVE_SYSTEMD=0 HAVE_ELOGIND=0

	cd "$builddir-elogind"
	make HAVE_SYSTEMD=0 HAVE_ELOGIND=1
}

package() {
	make install HAVE_SYSTEMD=0 HAVE_ELOGIND=0 PREFIX="/usr" DESTDIR="$pkgdir"

	install -D -m644 "$srcdir"/physlock.pam "$pkgdir"/etc/pam.d/physlock
}

elogind() {
	pkgdesc="$pkgdesc (with elogind support)"
	replaces="$pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel elogind"

	cd "$builddir-elogind"

	make install HAVE_SYSTEMD=0 HAVE_ELOGIND=1 PREFIX="/usr" DESTDIR="$subpkgdir"
	rm -Rf "$subpkgdir"/usr/share

	install -D -m644 "$srcdir"/physlock.pam "$subpkgdir"/etc/pam.d/physlock
}

sha512sums="
9d18a05f86c58100c050d086215709e7d4d9aeecd15c8e5af404d11950cde664a7bc8c19a746057bc7f8f40a74db4cb66e58a2084666f2cc720b0db488b9817a  physlock-4fbacee834abef613d7f4bd37d52a9f5fe269c82.tar.gz
c36a78c06f6557e83677eafadbc4c805df3ebde22a15050646076f592b4eb3523893416ea8570cb22c9d2c7638fc11d6a71d567517ceff266942b4502409e77d  physlock.pam
"
